package cn.school.dao;

import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class HtmlTag {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Document doc;
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		try {
			doc = Jsoup.connect("http://www.taobao.com/").get();
			Elements ehead = doc.getAllElements();
			for (Element e : ehead) {
				if (map.containsKey(e.tagName())) {
					map.put(e.tagName(), map.get(e.tagName()) + 1);

				} else {
					map.put(e.tagName(), 1);
				}

			}

		} catch (IOException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		Set<String> keys = map.keySet();
		Iterator<String> iter = keys.iterator();
		while (iter.hasNext()) {
			String key = iter.next();
			System.out.println(key + "\t" + map.get(key) + "次");
		}

	}

}